<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>阶乘</title>
</head>
<script>
    // sum表示总和
    // result表示每个阶乘的初始值
    var sum = 0
    var result = 1;
    for(var i=1; i<=10; i++) {
        result*=i
        sum+=result
        // 输出1-10的阶乘
        console.log(i+"!为 "+result)
    }
    console.log("1 ~ 10的阶乘的总和是" +sum)

</script>
<body>
    
</body>
</html>